<?php
class Training_LocaleController extends Zendvn_Controller_Action{
	public function init(){
		
	}
	public function index2Action(){
		/*$input = 13547.36;
		echo '<br>US: ' . $number = Zend_Locale_Format::toNumber($input,array('locale' => 'en_US'));
		echo '<br>VN: ' . $number = Zend_Locale_Format::toNumber($input,array('locale' => 'vi_VN'));*/
		
		
	/*	$input = 1000.121212;
		echo '<br>' . $number = Zend_Locale_Format::toNumber($input,array('locale'=>'en_US','precision'=>4));
		echo '<br>' . $number = Zend_Locale_Format::toNumber($input,array('locale'=>'vi_VN','precision'=>3));*/
		
		
		echo '<br>' . $input = 100100100.121212; // 1,000.12
		//1,000.12 => #,##0.#0
		//10,01,00.121 => #,#0.##0
		//1,001,00.12 =>  #,##0,#0.#0
		//1,00,100.12 =>  #,##,##0.#0
		echo '<br>' . $number = Zend_Locale_Format::toNumber($input,
																array('locale'=>'vi_VN',																		
																		'number_format'=>'#,##0.#0',
																)
															);
	
		$number = Zend_Locale_Format::getInteger('13.524,678',
								array('locale' => 'de_AT'));
			// will return 13524
		echo '<br>' .$number;
															

		$this->_helper->viewRenderer->setNoRender();
		
	}
	
	public function indexAction(){
		//1.Lay ngon ngu chính của trình duyệt
		$locale = new Zend_Locale('vi_VN');
		
		//2. Lay thong cac ngon ngu co trong trinh duyet
		$browser =  $locale->getBrowser();
		
		//3. 
		$charset = $locale->getHttpCharset();
		
		//4.
		$localeList = $locale->getLocaleList();
		
		//5.
		$languge = $locale->getLanguage();
		
		//6.
		$region = $locale->getRegion();
		
		//7.
		$list = $locale->getTranslationList('Territory','vi_VN',2);
		
		//8.
		$item = $locale->getTranslation('nl','language','vi_VN');
		$item = $locale->getTranslation('GB','territory','vi_VN');
		$item = $locale->getTranslation('84','TerritoryToPhone','vi_VN');
		$item = $locale->getTranslation('VND','NameToCurrency','vi_VN');
		
		/*echo '<br>' . $date = Zend_Locale_Format::getDateFormat('en_US');
		echo '<br>' . $date = Zend_Locale_Format::getDateFormat('vi_VN');
		echo '<br>' . $date = Zend_Locale_Format::getDateFormat('de_DE');*/
		//get IP -> Locale ->
		echo '<br>' . $time = Zend_Locale_Format::getTimeFormat('en_US');
		echo '<br>' . $time = Zend_Locale_Format::getTimeFormat('vi_VN');
		echo '<br>' . $time = Zend_Locale_Format::getTimeFormat('de_DE');
	
		
		$this->_helper->viewRenderer->setNoRender();
	}
}